using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Castle.ActiveRecord;

namespace EYDIngenieria.ERP.ObjetosDeNegocio.Dominio
{
    [ActiveRecord]
    public class Factura:ActiveRecordBase<Factura>
    {
        private int numeroFactura;
        private Proveedor proveedor;
        private MedioDePago medioDePago;
        private IList detalle = new ArrayList();
        private long montoTotal;
        private int id;
        private DateTime fecha;

        [Property]
        public DateTime Fecha
        {
            get { return fecha; }
            set { fecha = value; }
        }



        [PrimaryKey(PrimaryKeyType.Native)]
        public int Id
        {
            get { return id; }
            set { id = value; }
        }


        [Property]
        public long MontoTotal
        {
            get
            {
                //montoTotal = 0;
                //foreach (DetalleFactura detalle in Detalle)
                //{
                //    montoTotal = montoTotal + detalle.ValorTotal;
                //}
                return montoTotal;
            }
            set { montoTotal = value; }
        }


        [BelongsTo("IdMedioPago")]
        public MedioDePago MedioDePego
        {
            get { return medioDePago; }
            set { medioDePago = value; }
        }

        [BelongsTo("IdProveedor")]
        public Proveedor Proveedor
        {
            get { return proveedor; }
            set { proveedor = value; }
        }

       [Property]
        public int NumeroFactura
        {
            get { return numeroFactura; }
            set { numeroFactura = value; }
        }

        [HasMany(typeof(DetalleFactura))]
        public IList Detalle
        {
            get { return detalle; }
            set { detalle = value; }
        }

    }
}
